feat(devbox): add devbox.onEvict eviction notifications (SSE)#820
Merged
jrvb-rl merged 4 commits intoJul 24, 2026
Conversation
❌ Object Smoke Tests FailedTest Results❌ Some smoke tests failed Please fix the failing tests before checking coverage. |
|
⏹️ Reflex agent status: Stopped The agent was stopped. This PR was created by Reflex. This comment updates in place as the agent works. |
Contributor
Author
|
Reconciled with the endpoint as landed:
Ordering: depends on runloopai/runloop#10404, which marks |
jrvb-rl
force-pushed
the
feat/devbox-on-evict-sse
branch
from
July 24, 2026 09:34
c5c33b0 to
d8d6f4c
Compare
jrvb-rl
changed the base branch from
main
to
release-please--branches--main--changes--next--components--api-client
July 24, 2026 09:34
jrvb-rl
marked this pull request as ready for review
July 24, 2026 10:04
jason-rl
approved these changes
Jul 24, 2026
stainless-app
Bot
force-pushed
the
release-please--branches--main--changes--next--components--api-client
branch
from
July 24, 2026 16:00
3d5d772 to
fc944fc
Compare
Adds an object-oriented `Devbox.onEvict(callback)` backed by a per-client `EvictionMonitor`. The first registration opens a single account-wide `watchEvictions` SSE stream; incoming notifications are matched against the local interest set, the devbox is removed before its callback fires (at-most-once), and the stream is closed once the interest set empties. Depends on the Stainless-generated `devboxes.watchEvictions` method and `DevboxEvictionEvent` type, which land downstream once the server endpoint merges. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- Use the real generated event type DevboxEvictionEventView (the endpoint's view) in place of the assumed DevboxEvictionEvent. - Invoke the callback as callback(devbox, evictionDeadlineMs): the Devbox object and the Unix millisecond deadline, instead of passing the raw event. Requires the main-repo stainless config change that generates watchEvictions as Stream<DevboxEvictionEventView> (runloopai/runloop#10404). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Hermetic object-coverage test driving the shared EvictionMonitor via an in-memory fake watch_evictions stream: asserts onEvict fires once with (devbox, deadline), unmatched devbox ids are discarded, and cancelOnEvict aborts the stream. Gives the object-coverage suite 100% function coverage of the eviction wrapper without a live eviction. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Two bugs made devbox.onEvict never fire: 1. The generated watchEvictions() sends Accept: application/json, but the endpoint only streams for Accept: text/event-stream — otherwise it returns an empty text/plain 200. The monitor now forces the SSE Accept header. 2. The monitor ran the stream once and stopped. The server force-closes on leader change / slow consumer (and a long-lived HTTP/2 stream can drop), and expects the client to reconnect and re-read the snapshot. The monitor now reconnects with backoff until no devbox is still interested. Mirrors the api-client-python fix, verified against dev (a forced flex drain delivers on_evict for 20/20 devboxes before suspend). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
jrvb-rl
force-pushed
the
feat/devbox-on-evict-sse
branch
from
July 24, 2026 17:33
9f0afb1 to
3fcba8e
Compare
jrvb-rl
merged commit Jul 24, 2026
c4117b7
into
release-please--branches--main--changes--next--components--api-client
7 of 8 checks passed
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Follow-on to the server-side flex eviction-notification work (monorepo #10325 and its successor SSE endpoint). Adds the object-oriented client surface for eviction notifications.
New API:
devbox.onEvict(callback)(anddevbox.cancelOnEvict()) on theDevboxwrapper.How it works (internal state management):
EvictionMonitor(src/sdk/eviction.ts) holds the interest set:Map<devbox_id, callback>. Monitors are looked up via aWeakMap<Runloop, EvictionMonitor>(getEvictionMonitor), so everyDevboxbuilt from the same generated client shares one monitor and thus one SSE connection. NoDevbox/factory signatures changed.onEvictacross any devbox opens a single account-widedevboxes.watchEvictions()SSE stream via a backgroundfor awaitloop.AbortControlleris aborted and the stream closed. Re-registering re-opens it.Dependency / status
devboxes.watchEvictionsmethod and theDevboxEvictionEventtype (devbox_id,eviction_deadline_ms), which are generated downstream once the server endpoint lands. Those symbols are imported by assumed name from../resources/devboxes/devboxesand will be reconciled once generation lands. No generated code was modified.Note:
jest.config.objects.jsenforces 100% function coverage oversrc/sdk, so the object-oriented smoke test foronEvict/cancelOnEvict(plus a mockedtests/objectsunit test) is required and will be added when the endpoint is available to exercise.Testing
Deferred until the generated endpoint exists (see above).
🤖 Generated with Claude Code